package com.shujia.day11;

import java.util.Scanner;

/*
    字符串反转
    举例：键盘录入”abc”		输出结果：”cba”

 */
public class StringTest1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个字符串：");
        String str = sc.next();
        //将字符串转字符数组
        char[] chars = str.toCharArray(); //['a','b','c']

        for (int front = 0, end = chars.length - 1; front < end; front++, end--) {
            char tmp = chars[end];
            chars[end] = chars[front];
            chars[front] = tmp;
        }
        //['c','b','a']
        String resStr = new String(chars);
        System.out.println("反转后：" + resStr);


    }
}
